package bigoo.peer.message;

import bigoo.common.communication.AbstractMessage;
import bigoo.common.communication.InvalidMessageException;
import bigoo.common.communication.Message;
import bigoo.common.communication.MessageBuilder;

public class AcceptRideMessage extends AbstractMessage {

    public static final String MSG_IDENTIFIER = "ACCEPT_RIDE";
    private String requestID;

    public AcceptRideMessage(String senderID, String requestID) {
	super(senderID, MSG_IDENTIFIER);
	this.requestID = requestID;
    }

    public String getRequestID() {
	return this.requestID;
    }

    @Override
    public String getRawMessage() {
	return this.getSenderID() + SEPARATOR + MSG_IDENTIFIER + SEPARATOR + requestID + END_OF_MESSAGE;
    }

    public static class Builder implements MessageBuilder {
	@Override
	public Message parseMessage(String rawMessage) throws InvalidMessageException {
	    String senderID = parseSenderID(rawMessage);
	    String requestID = parseListParams(rawMessage)[0];
	    return new AcceptRideMessage(senderID, requestID);
	}
    }

}
